<?php
// Descriptions
echo '<br>Add table for users & messages';

$this->target->db->query("
    DROP TABLE IF EXISTS `" . DB_PREFIX . "messages`;
");

$this->target->db->query("
    CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "messages` (
      `id` bigint(20) unsigned NOT NULL auto_increment,
      `message` text NOT NULL,
      `language` varchar(4) NOT NULL default 'auto',
      `sender_id` bigint(20) unsigned NOT NULL default '0',
      `receiver_id` bigint(20) unsigned NOT NULL default '0',
      `is_read` enum('y','n') NOT NULL default 'n',
      `date` timestamp NOT NULL default CURRENT_TIMESTAMP,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
");

$this->target->db->query("
    DROP TABLE IF EXISTS `" . DB_PREFIX . "users`;
");

$this->target->db->query("
    CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "users` (
      `id` bigint(20) unsigned NOT NULL auto_increment,
      `email` varchar(64) NOT NULL,
      `name` varchar(64) NOT NULL default '',
      `password` varchar(32) NOT NULL default '' COMMENT 'MD5 hash',
      `language` varchar(4) NOT NULL default '',
      PRIMARY KEY  (`id`),
      UNIQUE KEY `email` (`email`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
");

$this->target->db->query("
    INSERT INTO `" . DB_PREFIX . "users` (`id`, `email`, `name`, `password`, `language`) VALUES
    (1, 'shesternin@gmail.com', 'Shesternin', 'c4ca4238a0b923820dcc509a6f75849b', 'en'),
    (2, 'a.shesternina@gmail.com', 'Shura', 'c4ca4238a0b923820dcc509a6f75849b', 'ru');
");


$this->target->db->query("
    DROP TABLE IF EXISTS `" . DB_PREFIX . "pages`;
");

$this->target->db->query("
    CREATE TABLE `" . DB_PREFIX . "pages` (
      `id` int(11) unsigned NOT NULL auto_increment,
      `parentId` int(11) default '0',
      `title` varchar(255) default NULL,
      `body` text,
      `menu_title` varchar(255) default NULL,
      `order` int(11) NOT NULL default '0',
      `alias` varchar(32) default NULL,
      `type` enum('page','news','city','transport') NOT NULL default 'page',
      `date` date NOT NULL default '0000-00-00',
      `metaDescription` text,
      `metaKeywords` varchar(255) default NULL,
      PRIMARY KEY  (`id`),
      UNIQUE KEY `alias` (`alias`,`type`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
");